﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DrawableObjects.Actors.Aircrafts;
using Sirian.DrawableObject.Actors;

namespace Serialization.Script
{
    /// <summary>
    /// A class representing formations. Aicrafts sent against the player will always appear in formations that decide about the order
    /// of the involved aircrafts.
    /// </summary>
    public abstract class Formation
    {
        public static Formation[] formations = 
        {
         new StraightLine_Formation(), 
         new V_Formation(), 
         new Victory_or_Death_Formation(),
         new WallOfDeath_Formation_Left(),
         new WallOfDeath_Formation_Right()
        };

        public string name
        {
            get;
            protected set;
        }

        public abstract void setFormation(List<Aircraft> aircrafts, Path basePath, Bounding visibleArea, Bounding useableArea);

        /// <summary>
        /// Finds the aicraft with the largest collission radius and returns this radius
        /// </summary>
        /// <param name="aircrafts"> A list of aircrafts that are checked.</param>
        /// <returns>The largest radius of those aircrafts.</returns>
        protected static float findMaxRadius(List<Aircraft> aircrafts)
        {
            float maxRadius = 0f;
            foreach (Aircraft aircraft in aircrafts)
            {
                maxRadius = aircraft.boundingSphere.Radius > maxRadius ? aircraft.boundingSphere.Radius : maxRadius;
            }
            return maxRadius;
        }

    }
}

